<style>
.jyui_cell_col .red {color: red;}
.fui-icon-group.col-7 .fui-icon-col {width: 14.28%;}
.signed {position: absolute;top:0;right:0.2rem;color:red;}
.fui-number .minus:before, .fui-number .plus:before {
	border-left: 0 solid #d9d9d9;
}
.fui-number .minus:after, .fui-number .plus:after {
	border-right: 0 solid #d9d9d9;
}
.fui-number:before {
	border-top: 0 solid #d9d9d9;
}
.fui-number:after {border-top: 0 solid #d9d9d9;}
.fui-number .num {
	color:#666;
}
.fui-number .num {
	color:#666;
}
.fui-number.small {
	height: 1.2rem;
	width: auto;
	line-height: 1.2rem;
}
.fui-number .minus, .fui-number .plus {
	z-index:0;
}
.fui-number.small .minus{
	color: {{main.syscolor || '#63BE72'}};
	padding-top:1px;
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
 .fui-number.small .plus {
	color: #fff;
	padding-top:1px;
	background: {{main.syscolor || '#63BE72'}};
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
</style>
<div ng-if="pagedata.showtimeset" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="height:25rem;overflow-y:scroll;padding-bottom:2.5rem">
			<i class="closed icon icon-cuowu" ng-click="pagedata.showtimeset=false"></i>
		<div>
		<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">预约配送商品类型/数量</div>
				<div class="fui-cellone-remark noremark">
				</div>
		</div>
		<div class="fui-cell-group radius" style="padding:0 0.15rem">
				<div class="fui-icon-group col-3">
					<div class="fui-icon-col-sm">
						<div class="text bold">商品名称</div>
					</div>
					<div class="fui-icon-col-sm">
						<div class="text bold">商品现有数量</div>
					</div>
					<div class="fui-icon-col-sm">
						<div class="text bold">操作</div>
					</div>
				</div>
				<div ng-repeat="g in pagedata.post.goods" class="fui-icon-group col-3">
					<div class="fui-icon-col-sm">
						<div class="info" style="font-size:0.6rem">{{g.goods_title}}</div>
						<div class="gray" style="font-size:0.6rem">规格：{{g.optiontitle || '无'}}</div>
					</div>
					<div class="fui-icon-col-sm">
						<div class="info bold">{{g.goodsnum || g.total}}</div>
					</div>	
					 <div class="fui-icon-col-sm">
                        <div class="label label-success" style="font-size:0.7rem" ng-click="pagedata.showsetgoods($index,g)"><i class="icon icon-qiehuan" style="font-size:0.7rem"></i> 设置</div>
                    </div>
                </div>
				<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.post.goods || pagedata.post.goods.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的商品!
				</div>
				<div style="padding:1rem">
					<a href="javascript:;" class="weui_btn weui_btn_primary" style="border-radius:1rem" ng-click="pagedata.upgoods();">提交数量规律设置</a>
				 </div>
		</div>
		<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">每日配送数量预览表：</div>
		</div>
		<div class="fui-cellone bold" style="padding:0;padding-bottom:0.3rem">
				<div ng-click="pagedata.upmonth(0);" class="fui-cellone-info" style="color:#18bc9c">
					<i class="icon icon-back" style="font-size:0.8rem"/>上月
				</div>
				<div class="fui-cellone-info c">
					{{pagedata.currentyear}}-{{pagedata.currentmonth}}
				</div>
				<div ng-click="pagedata.upmonth(1);" class="fui-cellone-info r" style="color:#18bc9c">
					下月<i class="icon icon-more" style="font-size:0.8rem"/>
				</div>
		</div>
		<div class="radius" style="background:#fff;padding-top:0.3rem">
				<div class="fui-icon-group noborder col-7">
					<div class="fui-icon-col" ng-repeat="week in pagedata.params.work_weekarray" style="margin-top:0">
						<label class="jyui_cell_col" style="color:#ddd">
							<div class="timetitle"><span>{{week}}</span></div>
						</label>
					</div>
				</div>
				<div class="fui-icon-group noborder col-7">
					<div class="fui-icon-col" ng-repeat="(k,value) in pagedata.kongday" style="margin-top:0">
						<label class="jyui_cell_col">
							
						</label>
					</div>
					<div class="fui-icon-col" ng-repeat="(k,value) in pagedata.calendar" style="margin-top:0">
						<div ng-class="{'jyui_cell_col':1,'disabled':value.islast==1}">
							<div>
								<div>{{value.i}}</div>
								<div style="font-size:0.5rem;line-height:1">
								<span ng-repeat="g in value.goods" ng-if="g.num>0">{{g.title}}(<span class="red">{{g.num}}</span>件)</span>
								</div>
							</div>
						</div>
					</div>
				</div>
		</div>
		<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">预约配送时间段选择！</div>
				<div class="fui-cellone-remark noremark">
				<span class="btn btn-sm btn-success" style="background:#18bc9c;line-height:2" ng-click="pagedata.post.peiset.times='';">清空</span>
				</div>
		</div>
		<div class="radius" style="background:#fff">
			<div class="fui-cellone">
					<div class="fui-cellone-label" style="color:#18bc9c">早</div>
					<div class="fui-cellone-info"></div>
					<div class="fui-cellone-remark noremark" style="color:#18bc9c">预约早上时间</div>
				</div>
				<div class="fui-icon-group noborder col-3" style="padding:0 0.15rem">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_hours0" style="margin-top:0">
						<label class="jyui_cell_col" ng-click="duoxuans(item.timev,pagedata.post.peiset,'times')">
							<div ng-class="{'btn btn-gray':1,'red':pagedata.post.peiset.times.indexOf(';'+item.timev+';')>=0}" style="background:#f2f2f2;margin: 0.1rem;line-height:2">{{item.timev}}</div>
						</label>
						<i ng-show="pagedata.post.peiset.times.indexOf(';'+item.timev+';')>=0" class="icon icon-selected signed" style="top:0.3rem"></i>
					</div>
					<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.work_hours0 || pagedata.work_hours0.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的时间!
					</div>
				</div>
				<div class="fui-cellone">
					<div class="fui-cellone-label" style="color:#18bc9c">中</div>
					<div class="fui-cellone-info"></div>
					<div class="fui-cellone-remark noremark" style="color:#18bc9c">预约中午时间</div>
				</div>
				<div class="fui-icon-group noborder col-3" style="padding:0 0.15rem">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_hours1" style="margin-top:0">
						<label class="jyui_cell_col" ng-click="duoxuans(item.timev,pagedata.post.peiset,'times')">
							<div ng-class="{'btn btn-gray':1,'red':pagedata.post.peiset.times.indexOf(';'+item.timev+';')>=0}" style="background:#f2f2f2;margin: 0.1rem;line-height:2">{{item.timev}}</div>
						</label>
						<i ng-show="pagedata.post.peiset.times.indexOf(';'+item.timev+';')>=0" class="icon icon-selected signed" style="top:0.3rem"></i>
					</div>
					<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.work_hours1 || pagedata.work_hours1.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的时间!
					</div>
				</div>
				<div class="fui-cellone">
					<div class="fui-cellone-label" style="color:#18bc9c">晚</div>
					<div class="fui-cellone-info"></div>
					<div class="fui-cellone-remark noremark" style="color:#18bc9c">预约晚上时间</div>
				</div>
				<div class="fui-icon-group noborder col-3" style="padding:0 0.3rem">
					<div class="fui-icon-col" ng-repeat="item in pagedata.work_hours2" style="margin-top:0">
						<label class="jyui_cell_col" ng-click="duoxuans(item.timev,pagedata.post.peiset,'times')">
							<div ng-class="{'btn btn-gray':1,'red':pagedata.post.peiset.times.indexOf(';'+item.timev+';')>=0}" style="background:#f2f2f2;margin: 0.1rem;line-height:2">{{item.timev}}</div>
						</label>
					</div>
					<div class='content-empty' style="margin:0.5rem 0" ng-show="!pagedata.work_hours2 || pagedata.work_hours2.length<=0">
						<i class='icon icon-information'></i><br/>暂时没有可设置的时间!
					</div>
				</div>
		</div>
        <div class="fui-cell-group">
                <div class="fui-cell small ">
                    <div class="fui-cell-info">
                        <label class="checkbox-inline">
                            <input type="checkbox" class="fui fui-checkbox fui-checkbox-danger" ng-checked="pagedata.post.peiset.agree==1" ng-model="pagedata.post.peiset.agree" /> 我已经阅读并了解了<a id="btn-apply" ng-click="pagedata.show_content=true" style="color:#337ab7;">【{{pagedata.yuyuexieyi.title}}】</a>。
                        </label>
                    </div>
                </div>
         </div>
         <div ng-show="pagedata.show_content" class="modal-bg pop-apply-hidden" >
                <div class="modal-content" style="top:10%;width:90%;left:5%">
                    <div class="closebtn" ng-click="pagedata.show_content=false" style="opacity:1;"><i class="icon icon-cuowu"></i></div>
                    <div class="news-body">
						<div class="title">{{pagedata.yuyuexieyi.title}} / <small>Read &nbsp;Ggree</small></div>
                        <div class="text" ng-bind-html="trust(pagedata.yuyuexieyi.content)"></div>
                    </div>
					<div class="modal-footer">
                            <div ng-click="pagedata.post.peiset.agree=1;pagedata.show_content=false" class="mod-check" style="width: 100%; margin: 0;">我已阅读</div>
                    </div>
                </div>
         </div>
		 </div>
		 <div style="padding:1rem">
			<a href="javascript:;" class="weui_btn weui_btn_primary" style="border-radius:1rem" ng-click="pagedata.showtimeset=false">提交设置</a>
		 </div>
</div>
</div>
</div>
<div ng-if="pagedata.showsetnum" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="min-height:auto">
			<div class="fui-cellone" style="text-align:left">
				<div class="fui-cellone-info bold">按星期设置[{{pagedata.nowgoods.goods_title}}]配送数量规律：</div>
				<div class="fui-cellone-remark noremark" ng-click="pagedata.post.goods[pagedata.nowkey]=pagedata.nowgoods;pagedata.showsetnum=false" style="color:#18bc9c">确定</div>
			</div>
			<div class="radius" style="background:#fff;padding-top:1rem">
				<div class="fui-icon-group noborder col-7">
					<div class="fui-icon-col" ng-repeat="week in pagedata.params.work_weekarray" style="margin-top:0">
						<label class="jyui_cell_col" style="color:#ddd">
							<div class="timetitle"><span>{{week}}</span></div>
						</label>
					</div>
				</div>
				<div class="fui-icon-group noborder col-7">
					<div class="fui-icon-col" ng-repeat="v in pagedata.nowgoods.numset" style="margin-top:0">
						<div class="weui_cell">
							<input type="text" class="weui_input" style="text-align:center;" placeholder="数量" ng-model="v.num"/>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script language='javascript'>
scope.pagedata.gotoshowtime=function(){
	scope.get('jy_peiorder/setpei/get_work_time/',function(res){
		scope.pagedata.work_hours0=res.hours0;
		scope.pagedata.work_hours1=res.hours1;
		scope.pagedata.work_hours2=res.hours2;
		scope.$evalAsync();
	});
}
scope.pagedata.gotoshowtime();
scope.pagedata.getDates=function(){
	scope.get('jy_peiorder/baodan/time_days/year='+scope.pagedata.currentyear+'&month='+scope.pagedata.currentmonth,function(res){
		console.log(scope.pagedata.currentyear);
		scope.pagedata.kongday=res.kongday;
		scope.pagedata.calendar=res.calendar;
		scope.$evalAsync()
		return true;
	});
}
scope.pagedata.getDates();
scope.pagedata.upmonth=function(isadd){
	var currentmonth=parseInt(scope.pagedata.currentmonth);
	if(isadd==1){
		if(currentmonth==12){
			currentmonth=1
			scope.pagedata.currentyear++
		}else{
			currentmonth++
		}
	}
	if(isadd!=1){
		if(currentmonth==1){
			currentmonth=12
			scope.pagedata.currentyear--
		}else{
			currentmonth--
		}
	}
	if(currentmonth<10){
		scope.pagedata.currentmonth='0'+currentmonth
	}
	scope.pagedata.getDates();
	return true;
}
scope.pagedata.upall=function(){
	var calendar = Object.values(scope.pagedata.calendar)
	for(var i=0;i<calendar.length;i++){
		var value=calendar[i]
		scope.duoxuans(value,scope.pagedata.post.peiset,'days')
	}
	scope.$evalAsync();
}
scope.pagedata.upgoods=function(){
	scope.post_json('jy_peiorder/baodan/postgoods/',scope.pagedata.post.goods,function(res){
		scope.pagedata.getDates();
		scope.message('刷新数量成功！');
		return true;
	});
}
scope.pagedata.showsetgoods=function(index,g){
	scope.pagedata.nowkey=index;
	if(!g.numset){
		g.numset=scope.pagedata.demonumset;
	}
	scope.pagedata.nowgoods=g;
	scope.pagedata.showsetnum=true
	scope.$evalAsync();
}
</script>